AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
local ENT = CAF.GetAddon("Resource Distribution")

include('shared.lua')

function ENT:Initialize()
	-- Create the physical of this entity
	self:SetModel( "models/props_wasteland/kitchen_fridge001a.mdl" )
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS )
	self:SetColor( 120, 96, 96, 255 )
	
	-- Wake the ohysics model if it is valid
	local phys = self:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
	end
	self:AddResource("12V Energy", 100)
	self:AddResource("energy", 1000)
	self:AddResource("Petrol", 800)
	self:AddResource("Crude Oil", 1000)
	self:AddResource("Oil", 800)
	self:AddResource(self.Entity, "hydrogen", 600)
	self:AddResource(self.Entity, "nitrogen", 600)
	self:AddResource(self.Entity, "oxygen", 600)
end

function ENT:SpawnFunction( ply, tr )
	-- Check the trace is OK
	if ( !tr.Hit ) then return end

	-- Create our entity
	local ent = ents.Create( "thecache" )
	slef:SetPos(tr.HitPos)
	self:Spawn()
	self:Activate()
	return ent
end

function ENT:Think()
self.BaseClass.Think(self)
end

function ENT:OnRemove()
	self.BaseClass.OnRemove(self)
end

//Duplicator support (TAD2020)
function ENT:PreEntityCopy()
	self.BuildDupeInfo(self.Entity)
	if (WireAddon == 1) then
		local DupeInfo = Wire_BuildDupeInfo(self.Entity)
		if DupeInfo then
			duplicator.StoreEntityModifier( self.Entity, "WireDupeInfo", DupeInfo )
		end
	end
end

function ENT:PostEntityPaste( Player, Ent, CreatedEntities )
	self.ApplyDupeInfo(Ent, CreatedEntities)
	if (WireAddon == 1) then
		if (Ent.EntityMods) and (Ent.EntityMods.WireDupeInfo) then
			Wire_ApplyDupeInfo(Player, Ent, Ent.EntityMods.WireDupeInfo, function(id) return CreatedEntities[id] end)
		end
	end
end
